<?php
namespace App\servers;

class RedisService
{
//    避免了连接的重复建立和资源浪费
    private static $instance = null;
    private $redis = null;
    private function __construct()
    {
        $this->redis = new \Redis();
        $this->redis->connect('43.143.96.235', 6379);
        $this->redis->auth('43.143.96.235');
    }

    private function __clone()
    {
        // TODO: Implement __clone() method.
    }

    //是否为 null，如果是，则创建一个新的 RedisServices 实例
    public static function getInstance()
    {
        if (is_null(self::$instance)) {
            self::$instance = new RedisService();
        }
        return self::$instance;
    }

    public function getRedis()
    {
        return $this->redis;
    }

}
